﻿using System;
using System.Collections.Generic;

namespace RexToy.Cassandra
{
    public static class MarshalFactory
    {
        private static IMarshal UTF8 = new UTF8Type();
        private static IMarshal Long = new LongType();
        private static IMarshal Date = new DateType();
        private static IMarshal Integer = new IntegerType();
        private static IMarshal LexicalUUID = new LexicalUUIDType();
        private static IMarshal Ascii = new AsciiType();

        public static IMarshal CreateMarshal(string javaClass)
        {
            switch (javaClass)
            {
                case "org.apache.cassandra.db.marshal.UTF8Type":
                    return UTF8;

                case "org.apache.cassandra.db.marshal.LongType":
                    return Long;

                case "org.apache.cassandra.db.marshal.DateType":
                    return Date;

                case "org.apache.cassandra.db.marshal.IntegerType":
                    return Integer;

                case "org.apache.cassandra.db.marshal.LexicalUUIDType":
                    return LexicalUUID;

                case "org.apache.cassandra.db.marshal.AsciiType":
                    return Ascii;
            }
            throw ExceptionHelper.CreateUnknownMarshaler(javaClass);
        }
    }
}
